
create table foo (
  id uuid not null,
  i int not null
);

ALTER TABLE ONLY foo ADD CONSTRAINT foo_uuid_key UNIQUE (id);

CREATE OR REPLACE FUNCTION insert_native_uuids(n integer) RETURNS int AS $$
  DECLARE r int;
  BEGIN
    FOR num IN 1..n LOOP
      insert into foo values (uuid(), num);
    END LOOP;
    RETURN n;
  END;
$$ LANGUAGE plpgsql;

create table bar (
  id varchar(36) not null,
  i int not null
);

ALTER TABLE ONLY bar ADD CONSTRAINT bar_uuid_key UNIQUE (id);

CREATE OR REPLACE FUNCTION fill_bar(n integer) RETURNS int AS $$
  DECLARE r int;
  BEGIN
    FOR num IN 1..n LOOP
      insert into bar values (uuid()::text, num);
    END LOOP;
    RETURN n;
  END;
$$ LANGUAGE plpgsql;

-- 

select fill_foo(500000);
select fill_bar(500000);

select pg_total_relation_size(foo);
select pg_total_relation_size(bar);
